﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QuizAppMvc2.Models.SubTopicoModels>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Create
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <h2>Create</h2>

    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Fields</legend>

            <%: Html.DropDownListFor(model => model.idMateria, new SelectList(Model.materias, "idmateria", "nome"), "Selecione a materia")%>
            <%: Html.DropDownListFor(model => model.idTopico, Enumerable.Empty<SelectListItem>(), "Selecione o tópico ") %>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.texto) %>
            </div>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.texto) %>
                <%: Html.ValidationMessageFor(model => model.texto) %>
            </div>
            
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>

     <script type="text/javascript">
         $(document).ready(function () {
             $("#idMateria").change(function () {
                 var url = '<%= Url.Content("~/") %>' + "Questao/abc";
                 var ddlsource = "#idMateria";
                 var ddltarget = "#idTopico";
                 $("#subtopico").empty();
                 $.getJSON(url, { year: $(ddlsource).val() }, function (data) {
                     $(ddltarget).empty();
                     $(ddltarget).append('<option value="">Selecione o topico</option>');
                     $.each(data, function (index, optionData) {
                         $(ddltarget).append("<option value='" + optionData.value + "'>" + optionData.novo + "</option>");
                     });
                 });
             });
         });


    
    </script>

</asp:Content>

